home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Stella Obscura 1.1 / source / Parts ƒ / Utilities.p < prev    next >
Encoding:
Text File  |  1990-05-13  |  24.6 KB  |  661 lines  |  [TEXT/PJMM]

  1. unit Utilities;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Sound, SomeGlobals;
  7.  
  8.     var
  9.         soundOn, slowOn, playing, pausing, gameOver, forgetSound: Boolean;
  10.         chanPtr: sndchannelptr;
  11.         playerShot: array[1..numberOfEnemies] of Boolean;
  12.         levelOn, elevationMode, shields, fireMode: Integer;
  13.         theScore: LongInt;
  14.         shieldString, scoreString: Str255;
  15.         mousePt: Point;
  16.         leftShipDst, rightShipDst, oldLeftShip, oldRightShip: Rect;
  17.         shipSrc, shipMaskSrc: array[0..4] of Rect;
  18.         crossHairSrc, crossHairMask: array[0..2] of Rect;
  19.         leftCrossHairDst, rightCrossHairDst, oldLeftCrossHair, oldRightCrossHair: Rect;
  20.         hoopOut: Boolean;
  21.         heightRatio: array[1..36] of Real;
  22.         hoopAngle, hoopDistance: Integer;
  23.         hoopSrc, hoopMask, leftHoopDst, rightHoopDst: Rect;
  24.         shieldSrc, leftShieldDst, rightShieldDst, bigClip: Rect;
  25.  
  26.     procedure DoTheSound (whichOne: Str255; asynch: Boolean);
  27.     procedure PredefineEnemyRects;
  28.     procedure SetShipsPos;
  29.     procedure ResetEnemy (whichOne, specifically: Integer);
  30.     procedure UpDateEnemy;
  31.     procedure ComputeHoops;
  32.     procedure PlayerFiredUpon (whoShot: Integer);
  33.     procedure DrawScene;
  34.     procedure HyperSpace3D;
  35.     procedure WrapItUp;
  36.  
  37. implementation
  38.  
  39. {=================================}
  40.  
  41.     procedure DoTheSound;
  42.         var
  43.             theSnd: Handle;
  44.             err: OSErr;
  45.     begin
  46.         if (soundOn) then
  47.             begin
  48.                 theSnd := GetNamedResource('snd ', whichOne);
  49.                 if (theSnd <> nil) and (ResError = noErr) then
  50.                     begin
  51.                         if (chanPtr <> nil) then
  52.                             begin
  53.                                 err := SndDisposeChannel(chanPtr, TRUE);
  54.                                 chanPtr := nil;
  55.                             end;
  56.                         if (asynch = true) and (SndNewChannel(chanPtr, 0, initMono, nil) = noErr) then
  57.                             err := SndPlay(chanPtr, theSnd, TRUE)
  58.                         else
  59.                             err := SndPlay(nil, theSnd, FALSE);
  60.                     end;
  61.             end;
  62.     end;
  63.  
  64. {=================================}
  65.  
  66.     procedure PredefineEnemyRects;
  67.         var
  68.             index, index2, enemyXPos, enemyYPos, enemyDistance, horiOff, vertOff, enemyDepth: Integer;
  69.             scale: Real;
  70.             rightEnemyDst, leftEnemyDst: Rect;
  71.     begin
  72.         enemyMaxCycles := (farthest - nearest) div enemySpeed + 1;
  73.         for index := 1 to 10 do
  74.             begin
  75.                 enemyXPos := DoRandom(2 * farthestStray) - farthestStray;
  76.                 enemyYPos := DoRandom(2 * farthestStray) - farthestStray;
  77.                 enemyDistance := farthest;
  78.                 index2 := 1;
  79.                 enemyDistance := enemyDistance - enemySpeed;
  80.                 enemySize[index, index2] := (enemyDistance - 10) div 32;
  81.                 if (enemySize[index, index2] > 8) then
  82.                     enemySize[index, index2] := 8;
  83.                 SetRect(leftEnemyDst, -14, -16, 14, 16);
  84.                 rightEnemyDst := leftEnemyDst;
  85.                 scale := nearest / enemyDistance * farthestStray;
  86.                 horiOff := TRUNC(enemyXPos * scale);
  87.                 vertOff := TRUNC(enemyYPos * scale);
  88.                 enemyDepth := ((10 - enemySize[index, index2]) div 2);
  89.                 OffsetRect(leftEnemyDst, horiOff + 63 + enemyDepth, vertOff + 120);
  90.                 OffsetRect(rightEnemyDst, horiOff + 63 - enemyDepth, vertOff + 120);
  91.                 theEnemies[index, leftWhole, index2] := leftEnemyDst;
  92.                 theEnemies[index, leftNew, index2] := leftEnemyDst;
  93.                 theEnemies[index, rightWhole, index2] := rightEnemyDst;
  94.                 theEnemies[index, rightNew, index2] := rightEnemyDst;
  95.                 for index2 := 2 to enemyMaxCycles do
  96.                     begin
  97.                         enemyDistance := enemyDistance - enemySpeed;
  98.                         enemySize[index, index2] := (enemyDistance - 10) div 32;
  99.                         if (enemySize[index, index2] > 8) then
  100.                             enemySize[index, index2] := 8;
  101.                         SetRect(leftEnemyDst, -14, -16, 14, 16);
  102.                         rightEnemyDst := leftEnemyDst;
  103.                         scale := nearest / enemyDistance * farthestStray;
  104.                         horiOff := TRUNC(enemyXPos * scale);
  105.                         vertOff := TRUNC(enemyYPos * scale);
  106.                         enemyDepth := ((10 - enemySize[index, index2]) div 2);
  107.                         OffsetRect(leftEnemyDst, horiOff + 63 + enemyDepth, vertOff + 120);
  108.                         OffsetRect(rightEnemyDst, horiOff + 63 - enemyDepth, vertOff + 120);
  109.                         UnionRect(leftEnemyDst, theEnemies[index, leftNew, index2 - 1], theEnemies[index, leftWhole, index2]);
  110.                         theEnemies[index, leftNew, index2] := leftEnemyDst;
  111.                         UnionRect(rightEnemyDst, theEnemies[index, rightNew, index2 - 1], theEnemies[index, rightWhole, index2]);
  112.                         theEnemies[index, rightNew, index2] := rightEnemyDst;
  113.                     end;
  114.             end;
  115.         enemyMaxCycles := enemyMaxCycles - 1;
  116.     end;
  117.  
  118. {=================================}
  119.  
  120.     procedure SetShipsPos;
  121.         var
  122.             horiOff, vertOff: Integer;
  123.     begin
  124.         GetMouse(mousePt);
  125.         SetRect(leftShipDst, -17, -11, 18, 12);
  126.         rightShipDst := leftShipDst;
  127.         horiOff := ((mousePt.h - 256) div 4);
  128.         vertOff := TRUNC((mousePt.v - 171) * 0.7);
  129.         OffsetRect(leftShipDst, horiOff + 63 + depth, vertOff + 120);
  130.         OffsetRect(rightShipDst, horiOff + 63 - depth, vertOff + 120);
  131.         elevationMode := (mousePt.v div 69);
  132.         if (elevationMode > 4) then
  133.             elevationMode := 4;
  134.  
  135.         SetRect(leftCrossHairDst, -6, -6, 5, 5);
  136.         rightCrossHairDst := leftCrossHairDst;
  137.         horiOff := (horiOff div 2);
  138.         vertOff := (vertOff div 2);
  139.         OffsetRect(leftCrossHairDst, horiOff + 63 + sightDepth, vertOff + 120);
  140.         OffsetRect(rightCrossHairDst, horiOff + 63 - sightDepth, vertOff + 120);
  141.  
  142.         if button and (fireMode = 0) then
  143.             begin
  144.                 fireMode := 2;
  145.                 DoTheSound('laserFire', TRUE);
  146.             end
  147.         else if (fireMode > 0) then
  148.             fireMode := fireMode - 1;
  149.     end;
  150.  
  151. {=================================}
  152.  
  153.     procedure ResetEnemy;
  154.         var
  155.             thePntr, dimen: Integer;
  156.             tempRect: Rect;
  157.     begin
  158.         enemiesPassed := enemiesPassed + 1;
  159.         thePntr := specifically;
  160.         playerShot[whichOne] := FALSE;
  161.         dimen := currentEnemies[whichOne, dataDimension];
  162.         tempRect := theEnemies[dimen, leftWhole, thePntr];
  163.         OffsetRect(tempRect, 129, 50);
  164.         CopyBits(offLeftVirginMap, mainWndo^.portBits, theEnemies[dimen, leftWhole, thePntr], tempRect, srcCopy, leftScreenRgn);
  165.         tempRect := theEnemies[dimen, rightWhole, thePntr];
  166.         OffsetRect(tempRect, 256, 50);
  167.         CopyBits(offRightVirginMap, mainWndo^.portBits, theEnemies[dimen, rightWhole, thePntr], tempRect, srcCopy, rightScreenRgn);
  168.         if (enemiesPassed > enemyMax) then
  169.             begin
  170.                 hoopOut := TRUE;
  171.                 CopyBits(offLeftVirginPort^.portBits, offLeftPort^.portBits, offLeftVirginMap.bounds, offLeftVirginMap.bounds, srcCopy, nil);
  172.                 CopyBits(offRightVirginPort^.portBits, offRightPort^.portBits, offRightVirginMap.bounds, offRightVirginMap.bounds, srcCopy, nil);
  173.                 CopyBits(offLeftPort^.portBits, mainWndo^.portBits, offLeftMap.bounds, leftBckgrndDst, srcCopy, nil);
  174.                 CopyBits(offRightPort^.portBits, mainWndo^.portBits, offRightMap.bounds, rightBckgrndDst, srcCopy, nil);
  175.             end
  176.         else
  177.             begin
  178.                 currentEnemies[whichOne, currentPointer] := 1;
  179.                 enemyShot[whichOne] := FALSE;
  180.                 currentEnemies[whichOne, dataDimension] := DoRandom(10) + 1;
  181.             end;
  182.     end;
  183.  
  184. {=================================}
  185.  
  186.     procedure UpDateEnemy;
  187.         var
  188.             index, thePntr, dimen: Integer;
  189.             dummyRect: Rect;
  190.     begin
  191.         for index := 1 to numberOfEnemies do
  192.             begin
  193.                 currentEnemies[index, currentPointer] := currentEnemies[index, currentPointer] + 1;
  194.                 thePntr := currentEnemies[index, currentPointer];
  195.                 dimen := currentEnemies[index, dataDimension];
  196.                 if (thePntr > enemyMaxCycles) then
  197.                     ResetEnemy(index, thePntr - 1);
  198.                 if (fireMode <> 0) and (enemySize[dimen, thePntr] = 5) and SectRect(oldLeftCrossHair, theEnemies[dimen, leftNew, thePntr], dummyRect) then
  199.                     begin
  200.                         enemyShot[index] := TRUE;
  201.                         ResetEnemy(index, thePntr - 1);
  202.                         theScore := theScore + 50;
  203.                         NumToString(theScore, scoreString);
  204.                         DoTheSound('enemyBoom', TRUE);
  205.                     end
  206.                 else if (enemySize[dimen, thePntr] < 5) then
  207.                     begin
  208.                         if (DoRandom(50) < levelOn) then
  209.                             playerShot[index] := TRUE;
  210.                     end;
  211.             end;
  212.     end;
  213.  
  214. {=================================}
  215.  
  216.     procedure ComputeHoops;
  217.         var
  218.             hoopWidth, hoopHeight, index: Integer;
  219.             center: Point;
  220.     begin
  221.         SetPort(offPlayerPort);
  222.         PenNormal;
  223.         hoopAngle := hoopAngle + flipSpeed;
  224.         if (hoopAngle > 36) then
  225.             hoopAngle := hoopAngle - 36;
  226.         hoopDistance := hoopDistance - travelSpeed;
  227.         if (hoopDistance < nearest) then
  228.             begin
  229.                 CopyBits(offLeftVirginPort^.portBits, offLeftPort^.portBits, offLeftVirginMap.bounds, offLeftVirginMap.bounds, srcCopy, nil);
  230.                 CopyBits(offRightVirginPort^.portBits, offRightPort^.portBits, offRightVirginMap.bounds, offRightVirginMap.bounds, srcCopy, nil);
  231.                 CopyBits(offLeftPort^.portBits, mainWndo^.portBits, offLeftMap.bounds, leftBckgrndDst, srcCopy, nil);
  232.                 CopyBits(offRightPort^.portBits, mainWndo^.portBits, offRightMap.bounds, rightBckgrndDst, srcCopy, nil);
  233.                 SetPt(center, 63, 120);
  234.                 if PtInRect(center, leftShipDst) then
  235.                     HyperSpace3D
  236.                 else
  237.                     begin
  238.                         enemiesPassed := 0;
  239.                         for index := 1 to numberOfEnemies do
  240.                             begin
  241.                                 playerShot[index] := FALSE;
  242.                                 enemyShot[index] := FALSE;
  243.                                 currentEnemies[index, currentPointer] := index;
  244.                             end;
  245.                         enemyMax := enemyMax + 10;
  246.                         hoopOut := FALSE;
  247.                         hoopAngle := 1;
  248.                         hoopDistance := farthest;
  249.                         ComputeHoops;
  250.                     end;
  251.             end
  252.         else
  253.             begin
  254.                 hoopWidth := TRUNC(nearest / hoopDistance * hoopSize) + 1;
  255.                 hoopHeight := TRUNC(hoopWidth * heightRatio[hoopAngle]) + 1;
  256.                 SetRect(hoopMask, 0, 0, hoopWidth, hoopHeight);
  257.                 hoopSrc := hoopMask;
  258.                 OffsetRect(hoopSrc, 328, 1);
  259.                 leftHoopDst := hoopMask;
  260.                 rightHoopDst := hoopMask;
  261.                 OffsetRect(hoopMask, 328, 103);
  262.                 EraseRect(hoopMask);
  263.                 OffsetRect(leftHoopDst, 64 - (hoopWidth div 2) + (hoopWidth div 10), 120 - (hoopHeight div 2));
  264.                 OffsetRect(rightHoopDst, 64 - (hoopWidth div 2) - (hoopWidth div 10), 120 - (hoopHeight div 2));
  265.                 PenSize((hoopWidth div 20) + 1, (hoopWidth div 20) + 1);
  266.                 FrameOval(hoopMask);
  267.             end;
  268.     end;
  269.  
  270. {=================================}
  271.  
  272.     procedure DrawHoopScene;
  273.         var
  274.             wholeLeftShip, wholeRightShip, wholeLeftCrossHair, wholeRightCrosshair: Rect;
  275.             tempRect, tempRect2, wholeLeftHoop, wholeRightHoop: Rect;
  276.     begin
  277.         wholeLeftHoop := leftHoopDst;
  278.         wholeLeftHoop.top := wholeLeftHoop.top - 5;
  279.         wholeLeftHoop.bottom := wholeLeftHoop.bottom + 5;
  280.         wholeRightHoop := rightHoopDst;
  281.         wholeRightHoop.top := wholeLeftHoop.top;
  282.         wholeRightHoop.bottom := wholeLeftHoop.bottom;
  283.         CopyBits(offLeftVirginMap, offLeftMap, wholeLeftHoop, wholeLeftHoop, srcCopy, nil);
  284.         CopyBits(offRightVirginMap, offRightMap, wholeRightHoop, wholeRightHoop, srcCopy, nil);
  285. {Get swatch for crosshair}
  286.         UnionRect(oldLeftCrossHair, leftCrossHairDst, wholeLeftCrossHair);
  287.         UnionRect(oldRightCrossHair, rightCrossHairDst, wholeRightCrosshair);
  288.         CopyBits(offLeftVirginMap, offLeftMap, wholeLeftCrossHair, wholeLeftCrossHair, srcCopy, nil);
  289.         CopyBits(offRightVirginMap, offRightMap, wholeRightCrosshair, wholeRightCrosshair, srcCopy, nil);
  290. {Get swatch for player's ship}
  291.         UnionRect(oldLeftShip, leftShipDst, wholeLeftShip);
  292.         UnionRect(oldRightShip, rightShipDst, wholeRightShip);
  293.         CopyBits(offLeftVirginMap, offLeftMap, wholeLeftShip, wholeLeftShip, srcCopy, nil);
  294.         CopyBits(offRightVirginMap, offRightMap, wholeRightShip, wholeRightShip, srcCopy, nil);
  295.  
  296.         CopyMask(offPlayerMap, offPlayerMap, offLeftMap, hoopSrc, hoopMask, leftHoopDst);
  297.         CopyMask(offPlayerMap, offPlayerMap, offRightMap, hoopSrc, hoopMask, rightHoopDst);
  298.         CopyMask(offPlayerMap, offPlayerMap, offLeftMap, crossHairSrc[fireMode], crossHairMask[fireMode], leftCrossHairDst);
  299.         CopyMask(offPlayerMap, offPlayerMap, offRightMap, crossHairSrc[fireMode], crossHairMask[fireMode], rightCrossHairDst);
  300.         CopyMask(offPlayerMap, offPlayerMap, offLeftMap, shipSrc[elevationMode], shipMaskSrc[elevationMode], leftShipDst);
  301.         CopyMask(offPlayerMap, offPlayerMap, offRightMap, shipSrc[elevationMode], shipMaskSrc[elevationMode], rightShipDst);
  302.  
  303.         tempRect := wholeLeftHoop;
  304.         OffsetRect(tempRect, 129, 50);
  305.         tempRect2 := wholeRightHoop;
  306.         OffsetRect(tempRect2, 256, 50);
  307.         CopyBits(offLeftMap, mainWndo^.portBits, wholeLeftHoop, tempRect, srcCopy, leftScreenRgn);
  308.         CopyBits(offRightMap, mainWndo^.portBits, wholeRightHoop, tempRect2, srcCopy, rightScreenRgn);
  309.         tempRect := wholeLeftCrossHair;
  310.         OffsetRect(tempRect, 129, 50);
  311.         tempRect2 := wholeRightCrossHair;
  312.         OffsetRect(tempRect2, 256, 50);
  313.         CopyBits(offLeftMap, mainWndo^.portBits, wholeLeftCrossHair, tempRect, srcCopy, nil);
  314.         CopyBits(offRightMap, mainWndo^.portBits, wholeRightCrossHair, tempRect2, srcCopy, nil);
  315.         tempRect := wholeLeftShip;
  316.         OffsetRect(tempRect, 129, 50);
  317.         tempRect2 := wholeRightShip;
  318.         OffsetRect(tempRect2, 256, 50);
  319.         CopyBits(offLeftMap, mainWndo^.portBits, wholeLeftShip, tempRect, srcCopy, leftScreenRgn);
  320.         CopyBits(offRightMap, mainWndo^.portBits, wholeRightShip, tempRect2, srcCopy, rightScreenRgn);
  321.  
  322.         SetPort(mainWndo);
  323.         PenNormal;
  324.         TextFont(0);
  325.         TextSize(12);
  326.         TextMode(NotSrcCopy);
  327.         MoveTo(145, 59);
  328.         DrawString('stargate ahead');
  329.         MoveTo(268, 59);
  330.         DrawString('stargate ahead');
  331.         TextFont(1);
  332.         TextSize(9);
  333.         MoveTo(152, 74);
  334.         DrawString(shieldString);
  335.         MoveTo(152, 280);
  336.         DrawString(scoreString);
  337.         MoveTo(273, 74);
  338.         DrawString(shieldString);
  339.         MoveTo(273, 280);
  340.         DrawString(scoreString);
  341.  
  342.         oldLeftShip := leftShipDst;
  343.         oldRightShip := rightShipDst;
  344.         oldLeftCrossHair := leftCrossHairDst;
  345.         oldRightCrossHair := rightCrossHairDst;
  346.     end;
  347.  
  348. {=================================}
  349.  
  350.     procedure PlayerFiredUpon;
  351.         var
  352.             thePntr, dimen: Integer;
  353.             tempRect, tempRect2: Rect;
  354.     begin
  355.         thePntr := currentEnemies[whoShot, currentPointer];
  356.         dimen := currentEnemies[whoShot, dataDimension];
  357.         playerShot[whoShot] := FALSE;
  358.         SetPort(mainWndo);
  359.         PenNormal;
  360.         PenMode(patXOr);
  361.         ClipRect(leftBckgrndDst);
  362.         MoveTo(leftShipDst.left + 147, leftShipDst.top + 72);
  363.         LineTo((theEnemies[dimen, leftNew, thePntr].left + theEnemies[dimen, leftNew, thePntr].right) div 2 + 129, (theEnemies[dimen, leftNew, thePntr].top + theEnemies[dimen, leftNew, thePntr].bottom) div 2 + 50);
  364.         tempRect := leftShipDst;
  365.         OffsetRect(tempRect, 129, 50);
  366.         InvertOval(tempRect);
  367.         ClipRect(rightBckgrndDst);
  368.         MoveTo(rightShipDst.left + 274, rightShipDst.top + 72);
  369.         LineTo((theEnemies[dimen, rightNew, thePntr].left + theEnemies[dimen, rightNew, thePntr].right) div 2 + 256, (theEnemies[dimen, rightNew, thePntr].top + theEnemies[dimen, rightNew, thePntr].bottom) div 2 + 50);
  370.         tempRect2 := rightShipDst;
  371.         OffsetRect(tempRect2, 256, 50);
  372.         InvertOval(tempRect2);
  373.         shields := shields - 1;
  374.         if (shields < 0) then
  375.             gameOver := TRUE;
  376.         NumToString(shields, shieldString);
  377.         DoTheSound('enemyFire', TRUE);
  378.         ClipRect(leftBckgrndDst);
  379.         MoveTo(leftShipDst.left + 147, leftShipDst.top + 72);
  380.         LineTo((theEnemies[dimen, leftNew, thePntr].left + theEnemies[dimen, leftNew, thePntr].right) div 2 + 129, (theEnemies[dimen, leftNew, thePntr].top + theEnemies[dimen, leftNew, thePntr].bottom) div 2 + 50);
  381.         InvertOval(tempRect);
  382.         ClipRect(rightBckgrndDst);
  383.         MoveTo(rightShipDst.left + 274, rightShipDst.top + 72);
  384.         LineTo((theEnemies[dimen, rightNew, thePntr].left + theEnemies[dimen, rightNew, thePntr].right) div 2 + 256, (theEnemies[dimen, rightNew, thePntr].top + theEnemies[dimen, rightNew, thePntr].bottom) div 2 + 50);
  385.         InvertOval(tempRect2);
  386.         ClipRect(bigClip);
  387.         CopyBits(offLeftVirginMap, mainWndo^.portBits, shieldSrc, leftShieldDst, srcCopy, nil);
  388.         CopyBits(offRightVirginMap, mainWndo^.portBits, shieldSrc, rightShieldDst, srcCopy, nil);
  389.     end;
  390.  
  391. {=================================}
  392.  
  393.     procedure DrawScene;
  394.         var
  395.             index, thePntr, dimen, theSize: Integer;
  396.             wholeLeftShip, wholeRightShip, wholeLeftCrossHair, wholeRightCrosshair: Rect;
  397.             tempRect, tempRect2: Rect;
  398.     begin
  399.         if (hoopOut) then
  400.             begin
  401.                 DrawHoopScene;
  402.                 Exit(DrawScene);
  403.             end;
  404.         for index := 1 to numberOfEnemies do
  405.             begin
  406.                 thePntr := currentEnemies[index, currentPointer];
  407.                 dimen := currentEnemies[index, dataDimension];
  408.                 CopyBits(offLeftVirginMap, offLeftMap, theEnemies[dimen, leftWhole, thePntr], theEnemies[dimen, leftWhole, thePntr], srcCopy, nil);
  409.                 CopyBits(offRightVirginMap, offRightMap, theEnemies[dimen, rightWhole, thePntr], theEnemies[dimen, rightWhole, thePntr], srcCopy, nil);
  410.             end;
  411. {Get swatch for crosshair}
  412.         UnionRect(oldLeftCrossHair, leftCrossHairDst, wholeLeftCrossHair);
  413.         UnionRect(oldRightCrossHair, rightCrossHairDst, wholeRightCrosshair);
  414.         CopyBits(offLeftVirginMap, offLeftMap, wholeLeftCrossHair, wholeLeftCrossHair, srcCopy, nil);
  415.         CopyBits(offRightVirginMap, offRightMap, wholeRightCrosshair, wholeRightCrosshair, srcCopy, nil);
  416. {Get swatch for player's ship}
  417.         UnionRect(oldLeftShip, leftShipDst, wholeLeftShip);
  418.         UnionRect(oldRightShip, rightShipDst, wholeRightShip);
  419.         CopyBits(offLeftVirginMap, offLeftMap, wholeLeftShip, wholeLeftShip, srcCopy, nil);
  420.         CopyBits(offRightVirginMap, offRightMap, wholeRightShip, wholeRightShip, srcCopy, nil);
  421.  
  422.         for index := 1 to numberOfEnemies do
  423.             begin
  424.                 thePntr := currentEnemies[index, currentPointer];
  425.                 dimen := currentEnemies[index, dataDimension];
  426.                 theSize := enemySize[dimen, thePntr];
  427.                 CopyMask(offPlayerMap, offPlayerMap, offLeftMap, enemySrc[theSize], enemyMaskSrc[theSize], theEnemies[dimen, leftNew, thePntr]);
  428.                 CopyMask(offPlayerMap, offPlayerMap, offRightMap, enemySrc[theSize], enemyMaskSrc[theSize], theEnemies[dimen, rightNew, thePntr]);
  429.             end;
  430.         CopyMask(offPlayerMap, offPlayerMap, offLeftMap, crossHairSrc[fireMode], crossHairMask[fireMode], leftCrossHairDst);
  431.         CopyMask(offPlayerMap, offPlayerMap, offRightMap, crossHairSrc[fireMode], crossHairMask[fireMode], rightCrossHairDst);
  432.         CopyMask(offPlayerMap, offPlayerMap, offLeftMap, shipSrc[elevationMode], shipMaskSrc[elevationMode], leftShipDst);
  433.         CopyMask(offPlayerMap, offPlayerMap, offRightMap, shipSrc[elevationMode], shipMaskSrc[elevationMode], rightShipDst);
  434.  
  435. {Drop enemies to screen}
  436.         for index := 1 to numberOfEnemies do
  437.             begin
  438.                 thePntr := currentEnemies[index, currentPointer];
  439.                 dimen := currentEnemies[index, dataDimension];
  440.                 tempRect := theEnemies[dimen, leftWhole, thePntr];
  441.                 OffsetRect(tempRect, 129, 50);
  442.                 CopyBits(offLeftMap, mainWndo^.portBits, theEnemies[dimen, leftWhole, thePntr], tempRect, srcCopy, leftScreenRgn);
  443.                 tempRect := theEnemies[dimen, rightWhole, thePntr];
  444.                 OffsetRect(tempRect, 256, 50);
  445.                 CopyBits(offRightMap, mainWndo^.portBits, theEnemies[dimen, rightWhole, thePntr], tempRect, srcCopy, rightScreenRgn);
  446.             end;
  447. {Drop crosshair to screen}
  448.         tempRect := wholeLeftCrossHair;
  449.         OffsetRect(tempRect, 129, 50);
  450.         CopyBits(offLeftMap, mainWndo^.portBits, wholeLeftCrossHair, tempRect, srcCopy, nil);
  451.         tempRect := wholeRightCrosshair;
  452.         OffsetRect(tempRect, 256, 50);
  453.         CopyBits(offRightMap, mainWndo^.portBits, wholeRightCrosshair, tempRect, srcCopy, nil);
  454. {Drop player's ship to screen}
  455.         tempRect := wholeLeftShip;
  456.         OffsetRect(tempRect, 129, 50);
  457.         CopyBits(offLeftMap, mainWndo^.portBits, wholeLeftShip, tempRect, srcCopy, leftScreenRgn);
  458.         tempRect := wholeRightShip;
  459.         OffsetRect(tempRect, 256, 50);
  460.         CopyBits(offRightMap, mainWndo^.portBits, wholeRightShip, tempRect, srcCopy, rightScreenRgn);
  461.  
  462.         SetPort(mainWndo);
  463.         PenNormal;
  464.         TextFont(1);
  465.         TextSize(9);
  466.         TextMode(NotSrcCopy);
  467.         MoveTo(153, 74);
  468.         DrawString(shieldString);
  469.         MoveTo(153, 280);
  470.         DrawString(scoreString);
  471.         MoveTo(273, 74);
  472.         DrawString(shieldString);
  473.         MoveTo(273, 280);
  474.         DrawString(scoreString);
  475.  
  476.         for index := 1 to numberOfEnemies do
  477.             if playerShot[index] then
  478.                 PlayerFiredUpon(index);
  479.         oldLeftShip := leftShipDst;
  480.         oldRightShip := rightShipDst;
  481.         oldLeftCrossHair := leftCrossHairDst;
  482.         oldRightCrossHair := rightCrossHairDst;
  483.     end;
  484.  
  485. {=================================}
  486.  
  487.     procedure HyperSpace3D;
  488.         var
  489.             index, index2: Integer;
  490.             blackHole, tempRect, tempRect2: Rect;
  491.             starPoints: array[1..30] of Point;
  492.             Trails: array[1..10, 1..30, 0..5] of Integer;
  493.     begin
  494.         SetPort(mainWndo);
  495.         tempRect := leftShipDst;
  496.         OffsetRect(tempRect, 129, 50);
  497.         tempRect2 := rightShipDst;
  498.         OffsetRect(tempRect2, 256, 50);
  499.  
  500.         DoTheSound('enterHole', TRUE);
  501.  
  502.         for index := 1 to 30 do
  503.             begin
  504.                 repeat
  505.                     SetPt(starPoints[index], (DoRandom(8) - 4) * 3, (DoRandom(8) - 4) * 3);
  506.                 until ((starPoints[index].h <> 0) and (starPoints[index].v <> 0));
  507.                 for index2 := 1 to 10 do
  508.                     begin
  509.                         Trails[index2, index, 0] := (192 + starPoints[index].h);
  510.                         Trails[index2, index, 1] := (170 + starPoints[index].v);
  511.                         Trails[index2, index, 2] := (starPoints[index].h * (index2 - 1) + index2);
  512.                         Trails[index2, index, 3] := (starPoints[index].v * (index2 - 1));
  513.                         Trails[index2, index, 4] := (starPoints[index].h * (index2 - 1) - index2);
  514.                         Trails[index2, index, 5] := (starPoints[index].v * (index2 - 1));
  515.                     end;
  516.                 SetRect(blackHole, 63 - index * 4, 120 - index * 4, 63 + index * 4, 120 + index * 4);
  517.                 OffsetRect(blackHole, 129 + index div 6, 50);
  518.                 ClipRect(leftBckgrndDst);
  519.                 FillOval(blackHole, black);
  520.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect);
  521.                 OffsetRect(blackHole, 127 - index div 3, 0);
  522.                 ClipRect(rightBckgrndDst);
  523.                 FillOval(blackHole, black);
  524.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect2);
  525.             end;
  526.  
  527.         levelOn := levelOn + 1;
  528.         enemiesPassed := 0;
  529.         enemyMax := levelOn * 5 + 5;
  530.         enemySpeed := (enemyMax - 10) div 4 + 5;
  531.         if enemyMax > 30 then
  532.             enemyMax := 30;
  533.         PredefineEnemyRects;
  534.         for index := 1 to numberOfEnemies do
  535.             begin
  536.                 playerShot[index] := FALSE;
  537.                 enemyShot[index] := FALSE;
  538.                 currentEnemies[index, currentPointer] := index;
  539.                 currentEnemies[index, dataDimension] := index;
  540.             end;
  541.         fireMode := 0;
  542.         shields := 10;
  543.         NumToString(shields, shieldString);
  544.         hoopOut := FALSE;
  545.         hoopAngle := 1;
  546.         hoopDistance := farthest;
  547.         ComputeHoops;
  548.  
  549.         DoTheSound('hyperSpace', TRUE);
  550.         SetPort(mainWndo);
  551.         PenNormal;
  552.         PenPat(white);
  553.         for index2 := 1 to 10 do
  554.             begin
  555.                 for index := 1 to 30 do
  556.                     begin
  557.                         ClipRect(leftBckgrndDst);
  558.                         MoveTo(Trails[index2, index, 0], Trails[index2, index, 1]);
  559.                         Line(Trails[index2, index, 2], Trails[index2, index, 3]);
  560.                         ClipRect(rightBckgrndDst);
  561.                         MoveTo(Trails[index2, index, 0] + 127, Trails[index2, index, 1]);
  562.                         Line(Trails[index2, index, 4], Trails[index2, index, 5]);
  563.                     end;
  564.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect);
  565.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect2);
  566.             end;
  567.  
  568.         PenPat(black);
  569.         PenSize(2, 2);
  570.         DoTheSound('hyperSpace', TRUE);
  571.         for index2 := 1 to 10 do
  572.             begin
  573.                 for index := 1 to 30 do
  574.                     begin
  575.                         ClipRect(leftBckgrndDst);
  576.                         MoveTo(Trails[index2, index, 0], Trails[index2, index, 1]);
  577.                         Line(Trails[index2, index, 2], Trails[index2, index, 3]);
  578.                         ClipRect(rightBckgrndDst);
  579.                         MoveTo(Trails[index2, index, 0] + 127, Trails[index2, index, 1]);
  580.                         Line(Trails[index2, index, 4], Trails[index2, index, 5]);
  581.                     end;
  582.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect);
  583.                 CopyMask(offPlayerMap, offPlayerMap, mainWndo^.portBits, shipSrc[elevationMode], shipMaskSrc[elevationMode], tempRect2);
  584.             end;
  585.         ClipRect(bigClip);
  586.         DoTheVirgin;
  587.     end;
  588.  
  589. {=================================}
  590.  
  591.     procedure WrapItUp;
  592.         var
  593.             index: Integer;
  594.             dummyLong: LongInt;
  595.             tempSrc, tempMask, tempLeft, tempRight, wholeLeft, wholeRight, tempRect: Rect;
  596.     begin
  597.         DoTheSound('enemyBoom', TRUE);
  598.         SetPort(mainWndo);
  599.         PenNormal;
  600.         PenPat(white);
  601.         tempLeft := leftShipDst;
  602.         OffsetRect(tempLeft, 129, 50);
  603.         tempRight := rightShipDst;
  604.         OffsetRect(tempRight, 256, 50);
  605.         for index := 1 to 50 do
  606.             begin
  607.                 ClipRect(leftBckgrndDst);
  608.                 FrameOval(tempLeft);
  609.                 ClipRect(rightBckgrndDst);
  610.                 FrameOval(tempRight);
  611.                 InsetRect(tempLeft, -2, -2);
  612.                 InsetRect(tempRight, -2, -2);
  613.             end;
  614.         ClipRect(bigClip);
  615.         SetPort(offPlayerPort);
  616.         SetRect(tempSrc, 328, 103, 328 + 91, 103 + 43);
  617.         EraseRect(tempSrc);
  618.         SetRect(tempMask, 226, 279, 317, 322);
  619.         tempLeft := tempMask;
  620.         OffsetRect(tempLeft, -226, -279);
  621.         tempRight := tempLeft;
  622.         OffsetRect(tempLeft, 18, 241);
  623.         OffsetRect(tempRight, 10, 241);
  624.         for index := 1 to 332 do
  625.             begin
  626.                 wholeLeft := tempLeft;
  627.                 wholeLeft.bottom := wholeLeft.bottom + 1;
  628.                 wholeRight := tempRight;
  629.                 wholeRight.bottom := wholeRight.bottom + 1;
  630.                 CopyBits(offLeftVirginMap, offLeftMap, wholeLeft, wholeLeft, srcCopy, nil);
  631.                 CopyBits(offRightVirginMap, offRightMap, wholeRight, wholeRight, srcCopy, nil);
  632.                 CopyMask(offPlayerMap, offPlayerMap, offLeftMap, tempSrc, tempMask, tempLeft);
  633.                 CopyMask(offPlayerMap, offPlayerMap, offRightMap, tempSrc, tempMask, tempRight);
  634.                 tempRect := wholeLeft;
  635.                 OffsetRect(tempRect, 129, 50);
  636.                 CopyBits(offLeftMap, mainWndo^.portBits, wholeLeft, tempRect, srcCopy, leftScreenRgn);
  637.                 tempRect := wholeRight;
  638.                 OffsetRect(tempRect, 256, 50);
  639.                 CopyBits(offRightMap, mainWndo^.portBits, wholeRight, tempRect, srcCopy, rightScreenRgn);
  640.                 OffsetRect(tempLeft, 0, -1);
  641.                 OffsetRect(tempRight, 0, -1);
  642.             end;
  643.  
  644.         Delay(150, dummyLong);
  645.  
  646.         DoTheVirgin;
  647.         ShowCursor;
  648.         EnableItem(GetMenu(AppleM), 0);
  649.         EnableItem(GetMenu(GameM), 1);
  650.         DisableItem(GetMenu(GameM), 2);
  651.         DisableItem(GetMenu(GameM), 3);
  652.         EnableItem(GetMenu(OptionsM), 0);
  653.         playing := FALSE;
  654.         pausing := FALSE;
  655.         SetEventMask(idleMask);
  656.         FlushEvents(everyEvent, 0);
  657.     end;
  658.  
  659. {=================================}
  660.  
  661. end.